<template>
  <div class="basic-info-form">
    <h3 class="section-title">基本信息</h3>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-form-item label="姓名" prop="name" required>
          <el-input 
            v-model="formData.name" 
            placeholder="请输入姓名"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="性别" prop="gender" required>
          <el-radio-group v-model="formData.gender">
            <el-radio label="男">男</el-radio>
            <el-radio label="女">女</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="出生日期" prop="birthdate" required>
          <el-date-picker
            v-model="formData.birthdate"
            type="date"
            placeholder="选择出生日期"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
            style="width: 100%"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'BasicInfoForm',
  props: {
    modelValue: {
      type: Object,
      default: () => ({
        name: '',
        gender: '',
        birthdate: ''
      })
    }
  },
  emits: ['update:modelValue'],
  data() {
    return {
      formData: { ...this.modelValue }
    }
  },
  watch: {
    modelValue: {
      handler(newVal) {
        this.formData = { ...newVal }
      },
      deep: true
    },
    formData: {
      handler(newVal) {
        this.$emit('update:modelValue', newVal)
      },
      deep: true
    }
  }
}
</script>

<style scoped>
.basic-info-form {
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #409eff;
}
</style> 